<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    request.setAttribute("path", path);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>地址管理</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link rel="stylesheet" type="text/css" href="${path}/css/css.css"/>
    <link rel="stylesheet" type="text/css" href="${path}/css/style.css"/>
    <link rel="stylesheet" type="text/css" href="${path}/css/menu.css"/>
    <link rel="stylesheet" type="text/css" href="${path}/css/address.css"/>
    <script type="text/javascript"
            src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="${path}/layer/layer.js" type="text/javascript"></script>
    <script src="${path}/js/main.js" type="text/javascript"></script>
    <script src="https://cdn.bootcss.com/distpicker/2.0.3/distpicker.js"></script>
    <script type="text/javascript">
        function updateType(t, id) {
            let orderType = $.trim(t.value);
            let orderId = id;
            console.log(orderId)
            console.log(orderType)
            $.get("OrderServlet/updateType", {
                "orderType": orderType,
                "orderId": orderId
            }, function (data) {
                if (data == 1) {
                    location.reload();
                } else {
                    layer.alert("操作失败");
                }
            }, "text")
        }

        /*禁用用户配送状态*/
        $(function () {

        })
    </script>
</head>
<body>
<div class="m-main">
    <div class="m-food">
        <div class="mf-top border-t">
            <div class="fl">
                订单管理
            </div>
            <div class="fr">
                <form action="OrderServlet/gotoOrder" method="post">
                    <input type="text" name="addTime" value="${addTime}" id="addTime" placeholder="下单时间"
                           style="width: 100px;"/>
                    -
                    <input type="text" name="updateTime" value="${updateTime}" id="updateTime" placeholder="下单时间"
                           style="width: 100px;"/>
                    -
                    <select class="select" name="orderType">
                        <option value="" selected>订单状态</option>
                        <option value="1">已下单</option>
                        <option value="2">配送中</option>
                        <option value="3">已完成</option>
                    </select>
                    -
                    <input type="text" name="orderId" value="${orderId}" id="orderId" placeholder="订单号"/>
                    <button type="submit">
                        查询
                    </button>
                </form>
            </div>
        </div>
        <c:forEach items="${oList}" var="list" varStatus="i">
            <div class="mf-menu border-t"
                 style="height: auto; line-height: normal; padding: 30px 0">
                <div class="fl">
                    <span class="m-wt1" style="width: 10px"></span>
                    <span>${list.orderId}</span>
                    <span>${list.userName}</span>
                    <span>${list.addTime}</span>
                    <span>${list.updateTime}</span>
                </div>
                <div class="fr weiyi">
                        <%--                    <input type="text" placeholder="已下单"--%>
                        <%--                           style="width: 70px; height: 22px; padding-left: 10px" />--%>
                    <c:if test="${sessionScope.user.userRole eq 'U'}">
                        <c:if test="${list.orderType eq 1}"><span>已下单</span></c:if>
                        <c:if test="${list.orderType eq 2}"><span>配送中</span></c:if>
                        <c:if test="${list.orderType eq 3}"><span>已完成</span></c:if>
                    </c:if>
                    <c:if test="${sessionScope.user.userRole eq 'A'}">
                    <select class="select" name="orderType" onchange="updateType(this,${list.orderId})">
                        <c:if test="${list.orderType eq 1}">
                            <option value="1" selected>已下单</option>
                            <option value="2">配送中</option>
                            <option value="3">已完成</option>
                        </c:if>
                        <c:if test="${list.orderType eq 2}">
                            <option value="1">已下单</option>
                            <option value="2" selected>配送中</option>
                            <option value="3">已完成</option>
                        </c:if>
                        <c:if test="${list.orderType eq 3}">
                            <option value="1">已下单</option>
                            <option value="2">配送中</option>
                            <option value="3" selected>已完成</option>
                        </c:if>
                    </select>
                    </c:if>
                    <button class="xiugai" style="padding: 10px"
                            onclick="change('order${i.count}',1)">
                        详情
                    </button>
                </div>
                <div id="update_order${i.count}" style="display: none;" class="change">
                    <c:forEach items="${list.tOrderDetails}" var="tList">
                        <div class=" clear" style="padding: 20px 0">
                            <span class="m-wt1" style="width: 28px"></span>
                            <span></span>
                            <span class="sp sp-1">${tList.productName}</span>
                            <span class="sp sp-2">${tList.productNum}</span>
                            <span class="sp sp-3">${tList.productMoney}</span>
                            <span class="sp sp-3" class="oSum">${tList.productMoney*tList.productNum}</span>
                        </div>
                    </c:forEach>
                    <div class=" clear" style="padding: 20px 0">
                        <span class="m-wt1" style="width: 28px"></span>
                        <span></span>
                        <span class="sp sp-4">送餐地址</span>
                        <span>${list.addressDetails}</span>
                        <span class="sp sp-4">总金额</span>
                        <span>${list.sum}</span>
                    </div>
                </div>
            </div>
        </c:forEach>
        <%-- 分页--%>
        <div class="mf-top" style="margin-top: 30px">
            <ul class="pagination" style="margin-left: 250px">
                <c:forEach begin="1" end="${totalPage}" var="i">
                    <%--   默认页--%>
                    <c:if test="${nowPage == i}">
                        <li><a class="active"
                               href="OrderServlet/gotoOrder?nowPage=${i}&addTime=${addTime}&updateTime=${updateTime}&orderType=${orderType}
                       &orderId=${orderId}">${i}</a></li>
                    </c:if>
                    <c:if test="${nowPage != i}">
                        <li>
                            <a href="OrderServlet/gotoOrder?nowPage=${i}&addTime=${addTime}&updateTime=${updateTime}&orderType=${orderType}
                       &orderId=${orderId}">${i}</a></li>
                    </c:if>
                </c:forEach>
            </ul>
        </div>

    </div>
</div>
</body>
</html>
<SCRIPT Language=VBScript><!--

//-->
</SCRIPT>
